package com.itHsuSE.demo2;

import java.util.Random;

public class Work14 {
}

class Tom{
    int tomGuessNum;
    int comGuessNum;
    int winCount;
    int count=1;

    public void info(){

    }

    public int computerNum(){
        Random r=new Random();
        comGuessNum=r.nextInt(3);
        return comGuessNum;
    }

    public void setTomGuessNum(int tomGuessNum) {
        if(tomGuessNum>2||tomGuessNum<0){
            throw new IllegalArgumentException("数字错误");
        }
        this.tomGuessNum=tomGuessNum;
    }

    public int getTomGuessNum() {
        return tomGuessNum;
    }

    public String vsComputer(){
        if(tomGuessNum==0&&comGuessNum==1){
            return "你赢了";
        }else if (tomGuessNum==1&&comGuessNum==2){
            return "你赢了";
        }else if (tomGuessNum==2&&comGuessNum==0){
            return "你赢了";
        }else if(tomGuessNum==comGuessNum){
            return "平手";
        }else {
            return "你输了";
        }
    }
}
